package com.siva.redis.template;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import com.siva.customer.domain.Customer;
import com.siva.redis.serializer.RedisObjectSerializer;

@Configuration
public class RedisConfig {
    
//    @Bean
//    JedisConnectionFactory jedisConnectionFactory() {
////        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
////        jedisConnectionFactory.setHostName("192.168.11.106");
////        jedisConnectionFactory.setPort(6379);
////        return jedisConnectionFactory;
//        return new JedisConnectionFactory();
//    }
    
    @Bean
    public RedisTemplate<String, Customer> redisTemplate(RedisConnectionFactory factory) {
        RedisTemplate<String, Customer> template = new RedisTemplate<String, Customer>();
        template.setConnectionFactory(factory);
        template.setKeySerializer(new StringRedisSerializer());
        template.setValueSerializer(new RedisObjectSerializer());
        return template;
    }
}
